package com.common.mybatis.plugins.pagination.dialect;

/**
 * 分页方言工厂类
 * 
 * @author songchangyou
 *
 */
public class DialectFactory {
  /**
   * <p>
   * 根据数据库类型选择不同分页方言
   * </p>
   * 
   * @param dbtype
   *          数据库类型
   * @return
   * @throws Exception
   */
  public static PageDialect getDialectByDbtype(String dbtype) throws Exception {
    if (DBDialectConstants.MYSQL.equalsIgnoreCase(dbtype)) {
      return new MySqlDialect();
    } else if (DBDialectConstants.ORACLE.equalsIgnoreCase(dbtype)) {
      return new OracleDialect();
    } else if (DBDialectConstants.HSQL.equalsIgnoreCase(dbtype)) {
      return new HSQLDialect();
    } else if (DBDialectConstants.SQLITE.equalsIgnoreCase(dbtype)) {
      return new SQLiteDialect();
    } else if (DBDialectConstants.POSTGRE.equalsIgnoreCase(dbtype)) {
      return new PostgreDialect();
    } else if (DBDialectConstants.SQLSERVER.equalsIgnoreCase(dbtype)) {
      return new SQLServerDialect();
    } else {
      return null;
    }
  }
}
